<?php
if (file_exists('../connect.php')) {
    include('../connect.php'); 
}
else
 include('../../connect.php'); 
$currentPage = isset($_REQUEST['curPage'])?$_REQUEST['curPage']:1;
$start = ($currentPage	-1) * $pagesize;		
$strSQL = "SELECT * FROM san where 1 LIMIT  $start, $pagesize";
//echo $strSQL;
$result = mysql_query($strSQL);
?>
<!--  start actions-box ............................................... -->
			<div id="actions-box">
				<a href="?actionadmin=Thêm Sân" title="Insert" class="action-slider">Thêm</a>
				<div class="clear"></div>
			</div>
			<!-- end actions-box........... -->
            
			<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
				<tr>
					<th class="table-header-repeat line-left minwidth-1" ><a href="">STT</a>	</th>
                    <th class="table-header-repeat line-left"><a href="">Mã Sân</a></th>
					<th class="table-header-repeat line-left"><a href="">Mô Tả</a></th>
					<th class="table-header-repeat line-left"><a href="">Hình</a></th>
					<th class="table-header-options line-left"><a href="">Tùy Chọn</a></th>
				</tr>
 <?php
 $i=$start;
while($r3 = mysql_fetch_assoc($result))
{
	$i++;
	$id=$r3["SanID"];
			$tieude=$r3["TieuDe"];
			$hinh=$r3["Hinh"];
			
			?>
             <!--  -->
				<tr>
					<td><?php echo "$i"; ?></td>
                    <td><?php echo "$id"; ?></td>
					<td><?php echo "$tieude"; ?></td>
                     <td><img src="../images/san/<?php echo "$hinh"; ?>" width="50"  height="70" /></td>
					<td class="options-width">
					<a href="?actionadmin=Update Sân&sanid=<?php echo "$id"; ?>&hinhold=<?php echo $hinh; ?>&curPage=<?php echo $currentPage; ?>" title="Edit" class="icon-1 info-tooltip"></a>
					<a href="?actionadmin=Delete Sân&sanid=<?php echo "$id"; ?>&curPage=<?php echo $currentPage; ?>" title="Delete" class="icon-2 info-tooltip"></a>
					</td>
				</tr>
   <?php 
   			}
    ?> 
  </table>
 <?php
$query = "SELECT count(*) as NUMROW FROM san where 1 ";
$result = mysql_query($query);	
$row = mysql_fetch_array($result);
$numrow = $row[0];
$numpage = ceil($numrow / ($pagesize*1.0));

//Style 
echo "<h2>";
if ($numpage>1)
{
	$next = $currentPage + 1;
     $prev = $currentPage - 1;
	 if($currentPage!=1)
	 		echo "<a style='cursor:pointer'href='?actionadmin=Sân&curPage=$prev'>Previous</a>&nbsp;&nbsp;&nbsp;"   ;  
for($i = 1 ; $i<= $numpage;$i++)
{
	if($i == $currentPage)
		echo $i."&nbsp;&nbsp;&nbsp;";
	else
	{
		echo "<a style='cursor:pointer' href='?actionadmin=Sân&curPage=$i'>".$i."</a>&nbsp;&nbsp;&nbsp;";
	}
}
	 if($currentPage != $numpage)
            echo "<a style='cursor:pointer' href='?actionadmin=Sân&curPage=$next'>Next</a>";
		echo "</h2>";
}
?>